package com.gitee.neuray.security.par.examperiod.biz;

import com.gitee.neuray.security.common.biz.BaseBiz;
import com.gitee.neuray.security.common.msg.TableResultResponse;
import com.gitee.neuray.security.common.util.Query;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.gitee.neuray.security.par.examperiod.mapper.ExamperiodMapper;
import com.gitee.neuray.security.par.examperiod.vo.ExamperiodVo;


@Service
@Transactional(rollbackFor = Exception.class)
public class ExamperiodBiz extends BaseBiz<ExamperiodMapper,ExamperiodVo> {
    @Autowired
    private ExamperiodMapper examperiodMapper;

    /**
     * 分页获取信息
     *
     * @param query
     * @return
     */
    public TableResultResponse page(Query query) {
        Page<Object> result = PageHelper.startPage(query.getPageNo(), query.getPageSize());
        List<ExamperiodVo> list = examperiodMapper.page(query);
        return new TableResultResponse(result.getPageSize(), result.getPageNum(), result.getPages(), result.getTotal(), list);
    }

    /**
     * 导出无分页
     *
     * @param query
     * @return
     */
    public List<ExamperiodVo> nopage(Query query) {
        return examperiodMapper.page(query);
    }

    /**
     * 检查考评周期名称是否存在
     * @param examperiodVo
     * @return
     */
    public int checkName(ExamperiodVo examperiodVo) {
        return examperiodMapper.checkName(examperiodVo);
    }

    /**
     * 删除时检查plan表是否含有引用
     * @param examperiodVo
     * @return
     */
    public int checkPlan(ExamperiodVo examperiodVo) {
        return examperiodMapper.checkPlan(examperiodVo);
    }

    @Override
    protected String getPageName() {
        return null;
    }
}
